﻿using System;

namespace Aeon.Framework
{

/// <summary>
/// Texture class wrapper for displaying textures in OpenGL.
/// Swaps cores to change state.
/// 
/// </summary>
public sealed class AeonTexture : ITexture
    {
    // --- Attributes:

    private String file;                                // File identifier.
    private TextureCore core;                           // File data.
    
    private TextureChanged observer;                    // Announcer for texture changes.
    
    // --- Properties:

    public TextureChanged Observer { get { return(observer); } set { observer = value; } }
    public TextureCore Core { get { return(core); } set { core = value; } }

    public String Name
        {
        get { return(file); }
        set {
            file = value;
            if (observer!=null) observer.Invoke(this); 
            }
        }

    public static ITexture None { get { return(new AeonTexture(TextureCore.NoData)); } }
    
    // --- Constructor:

    /// <summary>
    /// Private constructor, as all textures start from AeonTexture.None,
    /// 
    /// </summary>
    private AeonTexture(TextureCore texCore)
        {
        core = texCore;
        file = texCore.Path;
        }

    // --- Public Methods:

    /// <summary>
    /// Binds texture to active context.
    /// 
    /// </summary>
    public void Bind()
        {

        core.Bind();
        }

    }


}